package zhai.git.test;
// 静态代理
public class Main {
    public static void main(String[] args) {
        new Proxy(new Li()).merry();

        new Proxy(new Zhai()).merry();
    }
}

// 事情
interface Merry {
    void merry();
}
// A
class Li implements Merry{
    @Override
    public void merry() {
        System.out.println("A");
    }
}
// B
class Zhai implements Merry{
    @Override
    public void merry() {
        System.out.println("B");
    }
}
// 代理
class Proxy {
    private Merry target;

    public Proxy(Merry m) {
        target = m;
    }

    public void merry() {
        System.out.println("MMM");
        target.merry();
        System.out.println("MMM");
    }
}

